package com.digitalchina.lxnsy.viewholder;

import android.graphics.Paint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.CoinPresentVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：白彦东
 * 创建时间：2016/12/28 18:10
 * 修改备注：
 * ================================================
 */

public class CoinPresentListHolder extends BaseViewHolder<CoinPresentVO> {

    private SimpleDraweeView ivImage;
    private TextView tvTitle;
    private TextView tvPrice;
    private TextView tvOriginalPrice;
    private TextView tvNum;


    public CoinPresentListHolder(ViewGroup parent) {
        super(parent, R.layout.item_coin_present);
        ivImage = $(R.id.item_iv_images);
        tvTitle = $(R.id.item_tv_title);
        tvPrice = $(R.id.item_tv_price);
        tvNum = $(R.id.item_tv_num);
        tvOriginalPrice = $(R.id.item_tv_original_price);
    }

    @Override
    public void setData(CoinPresentVO data) {
        super.setData(data);

        FrescoUtil.showImageMid(data.getImage() != null ? data.getImage() : "", ivImage);
        tvTitle.setText(data.getName() + "");
        tvNum.setText("库存：" + data.getSurplusAmount());

        if (StringUtil.isStrEmpty(data.getActivityPrice())){
            tvOriginalPrice.setVisibility(View.GONE);
            tvPrice.setText(data.getPrice() + "");
        }else{
            tvOriginalPrice.setText(data.getPrice() + "农币"); // 原价
            tvPrice.setText(data.getActivityPrice() + ""); // 活动价
            tvOriginalPrice.setVisibility(View.VISIBLE);
            tvOriginalPrice.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG ); //中间横线
            tvOriginalPrice.getPaint().setAntiAlias(true);// 抗锯齿
        }

    }

}
